<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改数据库导出信息')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-sbrExpDbInfo-edit" th:object="${sbrExpDbInfo}">
        <input name="id" th:field="*{id}" type="hidden">
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">数据库信息：</label>
            <div class="col-sm-4">
                <input name="dbId" type="hidden" id="dbId" th:field="*{dbId}">
                <div class="input-group">
                    <input name="dbInfo" onclick="selectDbInfo()" th:field="*{dbInfo}" id="dbInfo" type="text" placeholder="请选择待导出的数据库信息" class="form-control" required>
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                </div>
            </div>
            <label class="col-sm-3 control-label is-required">导出数据库类型：</label>
            <div class="col-sm-3">
                <select name="dbType" class="form-control m-b" th:with="type=${@dict.getType('sbr_database_type')}" required>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{dbType}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label is-required">表空间名称：</label>
            <div class="col-sm-4">
                <input name="tableSchema" class="form-control" type="text" required th:field="*{tableSchema}">
            </div>
            <label class="col-sm-3 control-label is-required">是否导出数据：</label>
            <div class="col-sm-3">
                <select name="exportDataFlag" class="form-control m-b" th:with="type=${@dict.getType('sys_yes_no')}" required>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{exportDataFlag}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">备注：</label>
            <div class="col-sm-10">
                <textarea name="remark" class="form-control" th:field="*{remark}"></textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "sqlbuilder/sbrExpDbInfo";
    $("#form-sbrExpDbInfo-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-sbrExpDbInfo-edit').serialize());
        }
    }
    /**选择数据库信息*/
    function selectDbInfo() {
        var url = ctx + "sqlbuilder/sbrDatabase/selectTable";
        var options = {
            title: '选择数据库信息',
            width: "800",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero){
        var rows = layero.find("iframe")[0].contentWindow.getSelections();
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $("#dbId").val(rows[0].id);
        $("#dbInfo").val(rows[0].name);
        layer.close(index);
    }
</script>
</body>
</html>